<template>
  <div className="app-container">
    <div className="table-container">
      <base-list
        ref="table"
        url="/vip_price"
        :options="options"
        :columns="columns"
        :format="format"
        :rules="rules"
        permission="ADMIN"
        @reloadOptions="handleGetOptions"
      />
    </div>
  </div>
</template>

<script>
import {getBaseList, getBaseOptions} from '@/api/common'
import BaseList from '@/components/BaseList/index.vue'

export default {
  name: 'VipPrice',
  components: {BaseList},
  data() {
    return {
      columns: [
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'name', label: '标题', tooltip: '标题', type: 'WORD', queryable: true},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'role', label: '权益', tooltip: '权益', type: 'DICTIONARY', optionKey: 'roleOptions',queryable: true},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'initGift', label: '新用户赠送', tooltip: '新用户赠送', type: 'BOOLEAN'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'durationDay', label: '权益天数', tooltip: '权益天数', type: 'NUMBER'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'giftDay', label: '赠送权益天数', tooltip: '赠送权益天数', type: 'NUMBER'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'activeAtOnce', label: '立刻激活', tooltip: '是否可自行激活', type: 'BOOLEAN'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'price', label: '价格', tooltip: '价格', type: 'NUMBER'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'discount', label: '折扣', tooltip: '折扣', type: 'NUMBER'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'discountedPrice', label: '折扣价格', tooltip: '折扣价格', type: 'NUMBER'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'startDate', label: '开始时间', tooltip: '开始时间', type: 'DATE_TIME'},
        {show: true, edit: true, width: 'auto',minWidth: '200', key: 'endDate', label: '结束时间', tooltip: '结束时间', type: 'DATE_TIME'},
        {show: false, edit: false, width: 'auto',minWidth: '200', key: 'createTime', label: '创建时间', tooltip: '创建时间', type: 'DATE_TIME'},
        {show: true, edit: false, width: 'auto',minWidth: '200', key: 'updateTime', label: '更新时间', tooltip: '更新时间', type: 'DATE_TIME', queryable: true},
        {show: false, edit: false, width: 'auto',minWidth: '200', key: 'createUser', label: '创建人', tooltip: '创建人', type: 'WORD'},
        {show: false, edit: false, width: 'auto',minWidth: '200', key: 'updateUser', label: '修改人', tooltip: '修改人', type: 'WORD'},
      ],
      format: {},
      rules: {
        add: {
          role: [{required: true, message: '权益必填!', trigger: 'blur'}],
          durationDay: [{required: true, message: '权益天数必填!', trigger: 'blur'}],
          giftDay: [{required: true, message: '赠送权益天数必填!', trigger: 'blur'}],
          initGift: [{required: true, message: '初始赠送必填!', trigger: 'blur'}],
          activeAtOnce: [{required: true, message: '立刻激活必填!', trigger: 'blur'}],
          price: [{required: true, message: '价格必填!', trigger: 'blur'}],
          discount: [{required: true, message: '折扣必填!', trigger: 'blur'}],
          discountedPrice: [{required: true, message: '折扣价格必填!', trigger: 'blur'}],
          startDate: [{required: true, message: '开始时间必填!', trigger: 'blur'}],
          endDate: [{required: true, message: '结束时间必填!', trigger: 'blur'}],

        },
        edit: {
          id: [{required: true, message: '请选择数据!', trigger: 'change'}],
          role: [{required: true, message: '权益必填!', trigger: 'blur'}],
          durationDay: [{required: true, message: '权益天数必填!', trigger: 'blur'}],
          giftDay: [{required: true, message: '赠送权益天数必填!', trigger: 'blur'}],
          initGift: [{required: true, message: '初始赠送必填!', trigger: 'blur'}],
          activeAtOnce: [{required: true, message: '立刻激活必填!', trigger: 'blur'}],
          price: [{required: true, message: '价格必填!', trigger: 'blur'}],
          discount: [{required: true, message: '折扣必填!', trigger: 'blur'}],
          discountedPrice: [{required: true, message: '折扣价格必填!', trigger: 'blur'}],
          startDate: [{required: true, message: '开始时间必填!', trigger: 'blur'}],
          endDate: [{required: true, message: '结束时间必填!', trigger: 'blur'}],
        }
      },
      options: {
        roleOptions: [{id: 'VIP', name: '会员'}]
      }
    }
  },

  created() {
    this.handleGetOptions()
  },
  mounted() {
  },
  methods: {
    handleGetOptions() {
      const options = JSON.parse(localStorage.getItem('allOptions'))
      if (options) {
        this.options = Object.assign(this.options, options)
      }
    }
  }
}
</script>


